package com.sambo.inspection.component;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.sambo.inspection.R;

/**
 * Created by Administrator on 2015/6/25.
 */
public class ZnkProgressDialog extends Dialog {

      private Context mContent;

      private ZnkProgressDialog(Context context) {
            super(context, R.style.znk_dialog);
            mContent = context;
      }

      @Override
      protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

      }

      public static ZnkProgressDialog createLoadingDialog(Context context, String message) {

            View view = LayoutInflater.from(context).inflate(R.layout.dialog_loading, null);
            LinearLayout layout = (LinearLayout) view.findViewById(R.id.loading_view);
            ImageView loadingImg = (ImageView) view.findViewById(R.id.loading_img);
            TextView loadingTip = (TextView) view.findViewById(R.id.loading_tip);

            // 加载动画
            loadingImg.startAnimation(AnimationUtils.loadAnimation(context, R.anim.loading_anim));
            // 设置提示文字
            loadingTip.setText(message);

            ZnkProgressDialog dialog = new ZnkProgressDialog(context);
            dialog.setCanceledOnTouchOutside(false);
            dialog.setContentView(layout, new LinearLayout.LayoutParams(
                    LinearLayout.LayoutParams.MATCH_PARENT,
                    LinearLayout.LayoutParams.MATCH_PARENT));
            return dialog;
      }
}
